home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-09-13 | 12.7 KB | 327 lines | [TEXT/CCL2] |
-
- (in-package :TRAPS) ; ************************************************************
- ; Created: Wednesday, April 21, 1993
- ; Modified: Wed, Dec 1, 1993 16:39:45
- ;
- ; Components.p
- ; Pascal Interface to the Macintosh Libraries
- ;
- ; Copyright Apple Computer, Inc. 1990-93
- ; All rights reserved
- ; ************************************************************
-
- ; $IFC UNDEFINED UsingIncludes
- ; $SETC UsingIncludes := 0
- ; $ENDC
-
- ; $IFC NOT UsingIncludes
-
- ; $ENDC
-
- ; $IFC UNDEFINED UsingComponents
- ; $SETC UsingComponents := 1
-
- ; $I+
- ; $SETC ComponentsIncludes := UsingIncludes
- ; $SETC UsingIncludes := 1
- ; $IFC UNDEFINED UsingTypes
-
- (require-interface 'TYPES) ; $I $$Shell(PInterfaces)Types.p
- ; $ENDC
- ; $IFC UNDEFINED UsingTypes
-
- (require-interface 'MEMORY) ; $I $$Shell(PInterfaces)Memory.p
- ; $ENDC
- ; $SETC UsingIncludes := ComponentsIncludes
-
- ; $IFC UNDEFINED gestaltComponentMgrDeclared
- ; $SETC gestaltComponentMgrDeclared := True
- (defconstant $gestaltComponentMgr :|cpnt|)
- ; $ENDC
-
- (defconstant $kAnyComponentType 0)
- (defconstant $kAnyComponentSubType 0)
- (defconstant $kAnyComponentManufacturer 0)
- (defconstant $kAnyComponentFlagsMask 0)
-
- (defconstant $cmpWantsRegisterMessage #X80000000)
-
- ; Component Resource Extension flags
- (defconstant $componentDoAutoVersion 1)
- (defconstant $componentWantsUnregister 2)
- (defconstant $componentAutoVersionIncludeFlags 4)
-
- (defrecord ComponentDescription
- (componentType :OSTYPE) ; A unique 4-byte code indentifying the command set
- (componentSubType :OSTYPE) ; Particular flavor of this instance
- (componentManufacturer :OSTYPE); Vendor indentification
- (componentFlags :SIGNED-LONG); 8 each for Component,Type,SubType,Manuf/revision
- (componentFlagsMask :SIGNED-LONG); Mask for specifying which flags to consider in search, zero during registration
- )
-
- (defrecord ResourceSpec
- (resType :OSTYPE) ; 4-byte code
- (resId :SIGNED-INTEGER) ;
- )
-
- (def-mactype :COMPONENTRESOURCEPTR (find-mactype :POINTER))
- (def-mactype :COMPONENTRESOURCEHANDLE (find-mactype :HANDLE))
- (defrecord (ComponentResource :handle)
- (cd :COMPONENTDESCRIPTION) ; Registration parameters
- (component :RESOURCESPEC) ; resource where Component code is found
- (componentName :RESOURCESPEC); name string resource
- (componentInfo :RESOURCESPEC); info string resource
- (componentIcon :RESOURCESPEC); icon resource
- )
-
- (defrecord ComponentResourceExtension
- (componentVersion :SIGNED-LONG); version of Component
- (componentRegisterFlags :SIGNED-LONG); flags for registration
- (componentIconSuite :SIGNED-INTEGER); resource id of Icon Suite
- )
-
- (def-mactype :COMPONENTPTR (find-mactype :HANDLE))
- (def-mactype :COMPONENT (find-mactype :POINTER))
- (defrecord (ComponentRecord :handle)
- (data (:ARRAY :SIGNED-LONG 1))
- )
-
- (def-mactype :COMPONENTINSTANCE (find-mactype :POINTER))
- (defrecord ComponentInstanceRecord
- (data (:ARRAY :SIGNED-LONG 1))
- )
-
- ; Structure received by Component:
- (defrecord ComponentParameters
- (flags :CHARACTER) ; call modifiers: sync/async, deferred, immed, etc
- (paramSize :CHARACTER) ; size in bytes of actual parameters passed to this call
- (what :SIGNED-INTEGER) ; routine selector, negative for Component management calls
- (params (:ARRAY :SIGNED-LONG 1)); actual parameters for the indicated routine
- )
-
- (def-mactype :COMPONENTRESULT (find-mactype :SIGNED-LONG))
-
- (def-mactype :COMPONENTROUTINE (find-mactype :POINTER))
-
- (def-mactype :COMPONENTFUNCTION (find-mactype :POINTER))
-
- ; ******************************************************
- ; * Required Component routines
- ; ******************************************************
-
- (defconstant $kComponentOpenSelect -1); ComponentInstance for this open
- (defconstant $kComponentCloseSelect -2); ComponentInstance for this close
- (defconstant $kComponentCanDoSelect -3); selector # being queried
- (defconstant $kComponentVersionSelect -4); no params
- (defconstant $kComponentRegisterSelect -5); no params
- (defconstant $kComponentTargetSelect -6); ComponentInstance for top of call chain
- (defconstant $kComponentUnregisterSelect -7); no params
-
- ; Set Default Component flags
- (defconstant $defaultComponentIdentical 0)
- (defconstant $defaultComponentAnyFlags 1)
- (defconstant $defaultComponentAnyManufacturer 2)
- (defconstant $defaultComponentAnySubType 4)
- (defconstant $defaultComponentAnyFlagsAnyManufacturer (+ #$DEFAULTCOMPONENTANYFLAGS #$DEFAULTCOMPONENTANYMANUFACTURER))
- (defconstant $defaultComponentAnyFlagsAnyManufacturerAnySubType (+ #$DEFAULTCOMPONENTANYFLAGS (+ #$DEFAULTCOMPONENTANYMANUFACTURER #$DEFAULTCOMPONENTANYSUBTYPE)))
-
- ; errors from component manager & components
- (defconstant $invalidComponentID -3000)
- (defconstant $validInstancesExist -3001)
- (defconstant $componentNotCaptured -3002)
- (defconstant $componentDontRegister -3003)
-
- (defconstant $badComponentInstance #X80008001)
- (defconstant $badComponentSelector #X80008002)
-
- ; *******************************************************
- ; * *
- ; * APPLICATION LEVEL CALLS *
- ; * *
- ; *******************************************************
- ; * Component Database Add, Delete, and Query Routines
- ; *******************************************************
- ;
-
- (deftrap _registercomponent ((cd :componentdescription) (componententrypoint :pointer) (global :signed-integer) (componentname :handle) (componentinfo :handle) (componenticon :handle))
- (:stack (:pointer :componentrecord))
- (:stack-trap #xA82A :d0 1 cd componententrypoint global componentname componentinfo componenticon))
-
- (deftrap _registercomponentresource ((tr (:handle :componentresource)) (global :signed-integer))
- (:stack (:pointer :componentrecord))
- (:stack-trap #xA82A :d0 18 tr global))
-
- (deftrap _unregistercomponent ((acomponent (:pointer :componentrecord)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 2 acomponent))
-
-
- (deftrap _findnextcomponent ((acomponent (:pointer :componentrecord)) (looking :componentdescription))
- (:stack (:pointer :componentrecord))
- (:stack-trap #xA82A :d0 4 acomponent looking))
-
- (deftrap _countcomponents ((looking :componentdescription))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 3 looking))
-
-
- (deftrap _getcomponentinfo ((acomponent (:pointer :componentrecord)) (cd (:pointer :componentdescription)) (componentname :handle) (componentinfo :handle) (componenticon :handle))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 5 acomponent cd componentname componentinfo componenticon))
-
- (deftrap _getcomponentlistmodseed nil
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 6))
-
- ; *******************************************************
- ; * Component Instance Allocation and dispatch routines
- ; *******************************************************
- ;
-
- (deftrap _opencomponent ((acomponent (:pointer :componentrecord)))
- (:stack (:pointer :componentinstancerecord))
- (:stack-trap #xA82A :d0 7 acomponent))
-
- (deftrap _closecomponent ((acomponentinstance (:pointer :componentinstancerecord)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 8 acomponentinstance))
-
-
- (deftrap _getcomponentinstanceerror ((acomponentinstance (:pointer :componentinstancerecord)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 10 acomponentinstance))
-
- ; direct calls to the Components
-
- (deftrap _componentfunctionimplemented ((ci (:pointer :componentinstancerecord)) (ftnnumber :signed-integer))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 0 ci ftnnumber ((+ (ash 2 16) 65533) :signed-longint)))
-
- (deftrap _getcomponentversion ((ci (:pointer :componentinstancerecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 0 ci ((+ (ash 0 16) 65532) :signed-longint)))
-
- (deftrap _componentsettarget ((ci (:pointer :componentinstancerecord)) (target (:pointer :componentinstancerecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 0 ci target ((+ (ash 4 16) 65530) :signed-longint)))
-
- ; ****************************************************
- ; * *
- ; * CALLS MADE BY Components *
- ; * *
- ; ******************************************************
-
- ; *******************************************************
- ; * Component Management routines
- ; *******************************************************
- ;
-
- (deftrap _setcomponentinstanceerror ((acomponentinstance (:pointer :componentinstancerecord)) (theerror :signed-integer))
- nil
- (:stack-trap #xA82A :d0 11 acomponentinstance theerror))
-
-
- (deftrap _getcomponentrefcon ((acomponent (:pointer :componentrecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 16 acomponent))
-
- (deftrap _setcomponentrefcon ((acomponent (:pointer :componentrecord)) (therefcon :signed-long))
- nil
- (:stack-trap #xA82A :d0 17 acomponent therefcon))
-
-
- (deftrap _opencomponentresfile ((acomponent (:pointer :componentrecord)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 21 acomponent))
-
- (deftrap _closecomponentresfile ((refnum :signed-integer))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 24 refnum))
-
- ; *******************************************************
- ; * Component Instance Management routines
- ; *******************************************************
- ;
-
- (deftrap _getcomponentinstancestorage ((acomponentinstance (:pointer :componentinstancerecord)))
- (:stack :handle)
- (:stack-trap #xA82A :d0 12 acomponentinstance))
-
- (deftrap _setcomponentinstancestorage ((acomponentinstance (:pointer :componentinstancerecord)) (thestorage :handle))
- nil
- (:stack-trap #xA82A :d0 13 acomponentinstance thestorage))
-
-
- (deftrap _getcomponentinstancea5 ((acomponentinstance (:pointer :componentinstancerecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 14 acomponentinstance))
-
- (deftrap _setcomponentinstancea5 ((acomponentinstance (:pointer :componentinstancerecord)) (thea5 :signed-long))
- nil
- (:stack-trap #xA82A :d0 15 acomponentinstance thea5))
-
-
- (deftrap _countcomponentinstances ((acomponent (:pointer :componentrecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 19 acomponent))
-
- ; useful helper routines for convenient method dispatching
-
- (deftrap _callcomponentfunction ((params :componentparameters) (func :pointer))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 255 params func))
-
- (deftrap _callcomponentfunctionwithstorage ((storage :handle) (params :componentparameters) (func :pointer))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 255 storage params func))
-
- (deftrap _delegatecomponentcall ((originalparams :componentparameters) (ci (:pointer :componentinstancerecord)))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 36 originalparams ci))
-
-
- (deftrap _setdefaultcomponent ((acomponent (:pointer :componentrecord)) (flags :signed-integer))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 30 acomponent flags))
-
- (deftrap _opendefaultcomponent ((componenttype :ostype) (componentsubtype :ostype))
- (:stack (:pointer :componentinstancerecord))
- (:stack-trap #xA82A :d0 33 componenttype componentsubtype))
-
- (deftrap _capturecomponent ((capturedcomponent (:pointer :componentrecord)) (capturingcomponent (:pointer :componentrecord)))
- (:stack (:pointer :componentrecord))
- (:stack-trap #xA82A :d0 28 capturedcomponent capturingcomponent))
-
- (deftrap _uncapturecomponent ((acomponent (:pointer :componentrecord)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 29 acomponent))
-
- (deftrap _registercomponentresourcefile ((resrefnum :signed-integer) (global :signed-integer))
- (:stack :signed-long)
- (:stack-trap #xA82A :d0 20 resrefnum global))
-
- (deftrap _getcomponenticonsuite ((acomponent (:pointer :componentrecord)) (iconsuite (:pointer :handle)))
- (:stack :signed-integer)
- (:stack-trap #xA82A :d0 42 acomponent iconsuite))
-
- ; $ENDC ; UsingComponents
-
- ; $IFC NOT UsingIncludes
-
- ; $ENDC
-
-
- (export '($BADCOMPONENTSELECTOR $BADCOMPONENTINSTANCE $COMPONENTDONTREGISTER
- $COMPONENTNOTCAPTURED $VALIDINSTANCESEXIST $INVALIDCOMPONENTID
- $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURERANYSUBTYPE
- $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURER $DEFAULTCOMPONENTANYSUBTYPE
- $DEFAULTCOMPONENTANYMANUFACTURER $DEFAULTCOMPONENTANYFLAGS
- $DEFAULTCOMPONENTIDENTICAL $KCOMPONENTUNREGISTERSELECT
- $KCOMPONENTTARGETSELECT $KCOMPONENTREGISTERSELECT
- $KCOMPONENTVERSIONSELECT $KCOMPONENTCANDOSELECT
- $KCOMPONENTCLOSESELECT $KCOMPONENTOPENSELECT
- $COMPONENTAUTOVERSIONINCLUDEFLAGS $COMPONENTWANTSUNREGISTER
- $COMPONENTDOAUTOVERSION $CMPWANTSREGISTERMESSAGE
- $KANYCOMPONENTFLAGSMASK $KANYCOMPONENTMANUFACTURER
- $KANYCOMPONENTSUBTYPE $KANYCOMPONENTTYPE $GESTALTCOMPONENTMGR))
- (provide-interface 'Components)